#ifndef __LCD_H__
#define __LCD_H__


typedef enum {
    LCD_ST7789 = 0,
    LCD_SUM
}LCD_Type_t;

#define LCD_TYPE LCD_ST7789

/* 颜色枚举定义 */
typedef enum {
    LCD_Colour_NONE             = 0xFFFF + 1, // 不显示颜色(特殊值) 只适用于背景色
    LCD_Colour_BLACK            = 0x0000,     // 黑色
    LCD_Colour_RED              = 0xF800,     // 红色
    LCD_Colour_GREEN            = 0x07E0,     // 绿色
    LCD_Colour_BLUE             = 0x001F,     // 蓝色
    LCD_Colour_YELLOW           = 0xFFE0,     // 黄色
    LCD_Colour_CYAN             = 0x07FF,     // 青色
    LCD_Colour_MAGENTA          = 0xF81F,     // 品红色
    LCD_Colour_WHITE            = 0xFFFF,     // 白色
    LCD_Colour_GRAY             = 0x8410,     // 灰色
    LCD_Colour_NAVY             = 0x0010,     // 海军蓝
    LCD_Colour_OLIVE            = 0x8400,     // 橄榄绿
    LCD_Colour_PURPLE           = 0x8010,     // 紫色
    LCD_Colour_TEAL             = 0x0410,     // 水鸭色
    LCD_Colour_MAROON           = 0x8000,     // 栗色
    LCD_Colour_LIME             = 0x07E0,     // 酸橙色
    LCD_Colour_FUCHSIA          = 0xF81F,     // 紫红色
    LCD_Colour_AQUA             = 0x07FF,     // 浅绿色
    LCD_Colour_LIGHTGRAY        = 0xD69A,     // 浅灰色
    LCD_Colour_DARKGRAY         = 0x4210,     // 深灰色
    LCD_Colour_ORANGE           = 0xFD20,     // 橙色
    LCD_Colour_CORAL            = 0xFBEA,     // 珊瑚色
    LCD_Colour_KHAKI            = 0x8CE0,     // 卡其色
    LCD_Colour_ROSYBROWN        = 0xBC08,     // 玫瑰棕色
    LCD_Colour_SLATEGRAY        = 0x7412,     // 板岩灰
    LCD_Colour_LIGHTSTEELBLUE   = 0xB618,     // 浅钢蓝色
    LCD_Colour_LAVENDER         = 0xE6E6,     // 薰衣草色
    LCD_Colour_THISTLE          = 0x8B1F,     // 蓟色
    LCD_Colour_PLUM             = 0xDD1B,     // 洋李色
    LCD_Colour_VIOLET           = 0xEC1D,     // 紫罗兰色
    LCD_Colour_WHEAT            = 0xF7B2,     // 小麦色
    LCD_Colour_TAN              = 0xD590,     // 棕褐色
    LCD_Colour_SALMON           = 0xF4A0,     // 鲑鱼色
    LCD_Colour_MINTCREAM        = 0xF7FF,     // 薄荷奶油色
    LCD_Colour_SANDYBROWN       = 0xF5A0,     // 沙棕色
    LCD_Colour_GOLDENROD        = 0x07D6,     // 金菊黄
    LCD_Colour_SEASHELL         = 0xFFF5,     // 海贝壳色
    LCD_Colour_BEIGE            = 0xF7B2,     // 米色
    LCD_Colour_LIGHTSALMON      = 0xFD07,     // 浅鲑鱼色
    LCD_Colour_LIGHTCORAL       = 0xF810,     // 浅珊瑚色
    LCD_Colour_PALEGOLDENROD    = 0x07D6,     // 苍金菊黄
    LCD_Colour_PEACHPUFF        = 0xFEA0,     // 桃色
    LCD_Colour_LINEN            = 0xFFF0,     // 亚麻色
    LCD_Colour_ANTIQUEWHITE     = 0xFFFD,     // 古董白
    LCD_Colour_BISQUE           = 0xFFE4,     // 桔黄色
    LCD_Colour_PAPAYAWHIP       = 0xFFE7,     // 番木瓜色
    LCD_Colour_BLANCHEDALMOND   = 0xFFDE,     // 杏仁白
    LCD_Colour_MISTYROSE        = 0xFFE4,     // 雾玫瑰色
    LCD_Colour_LAVENDERBLUSH    = 0xFFE6,     // 薰衣草腮红色
    LCD_Colour_CORNSILK         = 0xFFF8,     // 玉米丝色
    LCD_Colour_SNOW             = 0xFFFA,     // 雪白色
    LCD_Colour_LIGHTCYAN        = 0xFFEF,     // 浅青色
    LCD_Colour_LIGHTYELLOW      = 0xFFFC      // 浅黄色
} LCD_ColourTypeDef;

/* 字体大小枚举定义 */
typedef enum {
    LCD_FontSize_12x6 = (12 << 16) | 6,  // 高12，宽6
    LCD_FontSize_16x8 = (16 << 16) | 8,  // 高16，宽8
    LCD_FontSize_20x10 = (20 << 16) | 10 // 高20，宽10
} LCD_FontSizeTypeDef;

// 定义SWAP宏，用于交换两个变量的值
#define SWAP(a, b) do { \
    typeof(a) temp = a; \
    a = b; \
    b = temp; \
   } while (0)

// 如果编译器不支持 typeof，可以使用以下版本
#undef SWAP
#define SWAP(a, b) do { \
    uint8_t temp = a; \
    a = b; \
    b = temp; \
   } while (0)

// 定义M_PI常量，如果未定义
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif 

#define true	1
#define false	0

void LCD_Init(void);

void LCD_WriteData_16Bit(uint16_t data);

void LCD_Clear(uint16_t color);
void LCD_SetWindows(uint16_t Start_X, uint16_t Start_Y,uint16_t End_X,uint16_t End_Y);
void LCD_SetCursor(uint16_t x, uint16_t y);
void LCD_Fill(uint16_t Start_X, uint16_t Start_Y, uint16_t End_X, uint16_t End_Y, uint16_t Color);
void LCD_SetOrientation(uint8_t orientation);


/* 显示驱动函数 */
void LCD_Show_Char(uint16_t X, uint16_t Y, char Char, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);
void LCD_Show_String(uint16_t X, uint16_t Y, const char* str, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);
void LCD_Show_uInt(uint16_t X, uint16_t Y, uint32_t num, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);
void LCD_Show_sInt(uint16_t X, uint16_t Y, int32_t num, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);
void LCD_Show_Float(uint16_t X, uint16_t Y, double Float, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);
void LCD_Show_Hex(uint16_t X, uint16_t Y, uint32_t Hex, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);
void LCD_Show_Bin(uint16_t X, uint16_t Y, uint32_t Bin, LCD_ColourTypeDef cFont, LCD_ColourTypeDef cBack, LCD_FontSizeTypeDef FontSize);

/* 绘图驱动函数 */
void LCD_Draw_Dot(uint16_t x,uint16_t y,uint16_t Data);
void LCD_Draw_Bezier(const uint16_t* xPoints, const uint16_t* yPoints, uint16_t numPoints, LCD_ColourTypeDef lColour);
void LCD_Draw_Polygon(const uint16_t* xPoints, const uint16_t* yPoints, uint8_t numPoints, LCD_ColourTypeDef lColour, LCD_ColourTypeDef fColour);
void LCD_Draw_FillPolygon(const uint16_t* xPoints, const uint16_t* yPoints, uint8_t numPoints, LCD_ColourTypeDef fColour);
void LCD_Draw_Line(uint16_t sX, uint16_t sY, uint16_t eX, uint16_t eY, LCD_ColourTypeDef lColour);
void LCD_Draw_Rectangle(uint16_t sX, uint16_t sY, uint16_t eX, uint16_t eY, LCD_ColourTypeDef lColour, LCD_ColourTypeDef fColour);
void LCD_Draw_Round(uint16_t sX, uint16_t sY, uint16_t radius, LCD_ColourTypeDef lColour, LCD_ColourTypeDef fColour);
void LCD_Draw_Triangle(const uint16_t* xPoints, const uint16_t* yPoints, LCD_ColourTypeDef lColour, LCD_ColourTypeDef fColour);
void LCD_Draw_Ellipse(uint16_t xc, uint16_t yc, uint16_t width, uint16_t height, LCD_ColourTypeDef lColour, LCD_ColourTypeDef fColour);
void LCD_Draw_Arc(uint16_t xc, uint16_t yc, uint16_t radius, uint8_t start_angle, uint8_t end_angle, LCD_ColourTypeDef lColour);




#endif /* __LCD_H__ */











































